package com.gitee.wsl.compose.mvi

import androidx.compose.foundation.layout.Column
import androidx.compose.material3.Divider
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
//import androidx.compose.ui.tooling.preview.Preview
import com.gitee.wsl.compose.state.S.state


interface SampleViewScope: ViewScope<SampleViewScope> {
    var testString:String
}


object SampleView: AbstractView<SampleViewScope>(), SampleViewScope {

    override var testString: String=""

    @Composable
    override fun OnCreateView(modifier: Modifier) {
        Column(modifier) {
            Text("hi I am a sample dsl view $testString", modifier)
            OnCreateChild(modifier)
        }
    }

}

@Composable
fun sampleView(modifier: Modifier = Modifier, configHk: SampleViewScope.(modifier: Modifier)->Unit){
    val view by state(SampleView.apply {
        Config(modifier,configHk)
    })
    view.Show()
}

/*
@Preview
@Composable
fun testSampleView(modifier: Modifier = Modifier){
    sampleView(modifier){

        testString="12121"

        onStarted {

        }

        body { _, modifier ->
            Divider()
            Text("hi I am a sample dsl child view", modifier)
        }

    }
}*/
